package com.zst.service.with.amqp.configuration;

import com.zst.amqp.PublisherConfirmCallbackContext;
import com.zst.amqp.config.BaseAmqpConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
public class SpringAmqpConfiguration extends BaseAmqpConfiguration {
    @Autowired
    private PublisherConfirmCallbackContext confirmCallbackContext;

    @PostConstruct
    public void registerConfirmCallback() {
        confirmCallbackContext.register("type00", (correlationId, ack) -> {
            System.err.println(correlationId + "___" + ack);
        });

        confirmCallbackContext.register("type01", (correlationId, ack) -> {
            System.err.println("type01 confirm callback called, ack result:" + ack);
        });
    }
}
